package com.ipt.frm.pw.listener;

import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Application Lifecycle Listener implementation class PropertiesListener
 * 
 */
public class PropertiesListener implements ServletContextListener {
	static Properties propertiesMsg;
	static final private String PATH_PROPERTIES_MSG = "/WEB-INF/config/messages.properties";

	/**
	 * Default constructor.
	 */
	public PropertiesListener() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see ServletContextListener#contextInitialized(ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent sce) {
		propertiesMsg = new Properties();
		try {
			ServletContext sc = sce.getServletContext();
			propertiesMsg.load(sc.getResourceAsStream(PATH_PROPERTIES_MSG));
			sc.setAttribute("propertiesMsg", propertiesMsg);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @see ServletContextListener#contextDestroyed(ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub
	}

}
